package modellayer;
import java.util.ArrayList;
import java.io.*;

/**
 * This class is a subclass to Person. 
 * 
 * @author (Kasper) 
 * @version (04.12.2014)
 */
public class Kunde extends Person implements Serializable
{
    private static int nextNo = 0;
    private int kundeNr;
    private String kundeLogin;
    private ArrayList<Ordre> kOrdre;

    /**
     * Constructor for objects of class Kunde
     */
    public Kunde(String navn, String adresse, String postnr, String by, String tlf, String email)
    {
        super(navn, adresse, postnr, by, tlf, email);
        nextNo++;
        kundeNr = nextNo;
        kOrdre = new ArrayList<Ordre>();
    }
    
    public void kundeNoCounter()
    {
        nextNo++;
    }
    
    public int getStaticCounter()
    {
        return nextNo;
    }

    public void addOrdre(Ordre o)
    {
        kOrdre.add(o);
    }
    
    public ArrayList<Ordre> getOList()
    {
        return kOrdre;
    }

    public void removeOrdre(Ordre o)
    {
        if(kOrdre.contains(o))
        {
            kOrdre.remove(o);
        }
    }

    /**
     * Method getKundeNr
     *
     * @return kundenummer
     */
    public int getKundeNr()
    {
        return kundeNr;
    }

    /**
     * Method setKundeNr
     *
     * @param kundenummer
     */
    public void setKundeNr(int kundeNr)
    {
        this.kundeNr = kundeNr;
    }

    /**
     * Method getKundeLogin
     *
     * @return kunde login
     */
    public String getKundeLogin()
    {
        return kundeLogin;
    }

    /**
     * Method setKundeLogin
     *
     * @param kunde login
     */
    public void setKundeLogin(String kundeLogin)
    {
        this.kundeLogin = kundeLogin;
    }

    /**
     * Returns a String with information about a customer
     *
     * @return text
     */
    public String toString()
    {
        String text = 
            super.toString() +
            "Kundenummer: " + kundeNr + "\n" +
            "Kunde login: " + kundeLogin + "\n";

        return text;
    }
}
